﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace Segmentation.Business
{
    class ColorCollection
    {
        private List<Color> colors = new List<Color>();
        private Random rand = new Random(1);

        public ColorCollection()
        {
            Fill();
        }

        private void Fill()
        {
            this.colors.Clear();
            foreach (KnownColor color in Enum.GetValues(typeof(KnownColor)))
            {
                Color rgb = Color.FromKnownColor(color);
                if (!rgb.IsSystemColor)
                {
                    this.colors.Add(rgb);
                }
            }
        }

        public Color GetRandomColor()
        {
            if (this.colors.Count == 0)
            {
                Fill();
            }
            int index = this.rand.Next(this.colors.Count);
            Color result = this.colors[index];
            this.colors.RemoveAt(index);
            return result;
        }
    }
}
